package com.example.demo.设计模式.代理模式.动态代理.JDK代理;

import java.lang.reflect.Proxy;

/**
 * @description:
 * @projectName:demo
 * @see:设计模式.代理模式.动态代理.JDK代理
 * @author:袁成龙
 * @createTime:2020/10/12 19:06
 * @version:1.0
 */
public class TestJDK {

    public static void main(String[] args) {

       /* Test01IntefaceImpl test01Inteface = new Test01IntefaceImpl();

        Test01 test01 = new Test01(test01Inteface);

      //  Class<?>[] interfaces = Test01IntefaceImpl.class.getInterfaces();

        Class<?>[] interfaces ={Test01Interface.class};

        Test01Interface o = (Test01Interface)Proxy.newProxyInstance(Test01Interface.class.getClassLoader(), interfaces, test01);

        System.out.println(o.test());*/




       //不用实现类直接对接口进行操作
        Test02 test02 = new Test02();
        Class<?>[] interfaces ={Test02Interface.class};
        Test02Interface o = (Test02Interface) Proxy.newProxyInstance(Test02Interface.class.getClassLoader(), interfaces, test02);
        System.out.println(o.test("1111111"));
    }

}